// Source File Name:   ENImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.common.VersionInfo;
import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.EN;
import com.sunwayhorizo.health.hl7.datatypes.ENXP;
import com.sunwayhorizo.health.hl7.datatypes.IVL_TS;
import com.sunwayhorizo.health.hl7.datatypes.SET_CS;
import com.sunwayhorizo.health.hl7.datatypes.ST;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;

import java.util.Arrays;
import java.util.List;

//            ENCommonImpl, ANYImpl, BLImpl, CSImpl,
//            TYPEImpl

public class ENImpl extends ENCommonImpl implements EN
{

    public static final String RCS_ID = "$Header: ENImpl.java 115.19 2005/09/16 09:23:53 amchanda noship $";
    public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header: ENImpl.java 115.19 2005/09/16 09:23:53 amchanda noship $",
        "oracle.apps.ctb.hl7.types.common");
    private static final String USE = "use";
    private static final String VALID_TIME = "validTime";
    
    private static final EN nullNI = new ENImpl(CSImpl.valueOf("NI"));
    private static final EN nullOTH = new ENImpl(CSImpl.valueOf("OTH"));
    private static final EN nullNINF = new ENImpl(CSImpl.valueOf("NINF"));
    private static final EN nullPINF = new ENImpl(CSImpl.valueOf("PINF"));
    private static final EN nullUNK = new ENImpl(CSImpl.valueOf("UNK"));
    private static final EN nullASKU = new ENImpl(CSImpl.valueOf("ASKU"));
    private static final EN nullNAV = new ENImpl(CSImpl.valueOf("NAV"));
    private static final EN nullMSK = new ENImpl(CSImpl.valueOf("MSK"));
    private static final EN nullNA = new ENImpl(CSImpl.valueOf("NA"));
    private static final EN nullNASK = new ENImpl(CSImpl.valueOf("NASK"));


    public static EN valueOf(List list, SET_CS set_cs, IVL_TS ivl_ts)
    {
        return new ENImpl(list, set_cs, ivl_ts);
    }


    public static EN valueOf(ST name, CS use)
    {
        return new ENImpl(name, use);
    }


    public static EN valueOf(ENXP aenxp[], SET_CS set_cs, IVL_TS ivl_ts, ST st)
    {
        return new ENImpl(aenxp, set_cs, ivl_ts, st);
    }
    
    public static EN valueOf(ENXP aenxp[], SET_CS set_cs, IVL_TS ivl_ts, ST st,ST flag)
    {
        return new ENImpl(aenxp, set_cs, ivl_ts, st,flag);
    }


    public static EN valueOf(ENXP aenxp[], SET_CS set_cs, IVL_TS ivl_ts)
    {
        return new ENImpl(aenxp, set_cs, ivl_ts);
    }


    protected ENImpl(List list, SET_CS set_cs, IVL_TS ivl_ts)
    {
        super(list, set_cs, ivl_ts);
    }


    protected ENImpl(CS cs)
    {
        super(cs);
    }


    protected ENImpl(ENXP aenxp[], SET_CS set_cs, IVL_TS ivl_ts, ST st)
    {
        super(Arrays.asList(aenxp), set_cs, ivl_ts, st);
    }

    protected ENImpl(ENXP aenxp[], SET_CS set_cs, IVL_TS ivl_ts, ST st,ST flag)
    {
        super(Arrays.asList(aenxp), set_cs, ivl_ts, st,flag);
    }

    protected ENImpl(ENXP aenxp[], SET_CS set_cs, IVL_TS ivl_ts)
    {
        super(Arrays.asList(aenxp), set_cs, ivl_ts);
    }


    protected ENImpl(ST name, CS use2)
    {
        _formatted = name;
        _use = SET_CSImpl.valueOf(use2);

    }

    @Override
    public ST formattedFlag()
    {
        return _formattedFlag;
    }
    
    public TYPE dataType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.EN;
    }


    public BL equal(ANY any)
    {
        if (!(any instanceof EN))
            return BLImpl.FALSE;
        if (isNull().or(any.isNull()).isTrue())
            return BLImpl.FALSE;
        else
            return super.equal(any);
    }


    public int hashCode()
    {
        return super.hashCode();
    }


    public static EN nullEN(CS cs)
    {
        String s = null;
        if (cs == null || cs.literal().stringValue() == null || cs.isNull().isTrue())
            s = "NI";
        else
            s = cs.literal().stringValue();
        if (s.equals("NI"))
            return nullNI;
        if (s.equals("OTH"))
            return nullOTH;
        if (s.equals("NINF"))
            return nullNINF;
        if (s.equals("PINF"))
            return nullPINF;
        if (s.equals("UNK"))
            return nullUNK;
        if (s.equals("ASKU"))
            return nullASKU;
        if (s.equals("NAV"))
            return nullNAV;
        if (s.equals("MSK"))
            return nullMSK;
        if (s.equals("NA"))
            return nullNA;
        if (s.equals("NASK"))
            return nullNASK;
        else
            return nullNI;
    }


   

}
